#pragma once
#include "CXcpObjectBase.h"
#include "CXcpObjectThreadSafeAddRefPolicy.h"
#include "IPALTickableClock.h"

class RefreshAlignedClock :
	public CXcpObjectBase<IPALTickableClock,CXcpObjectThreadSafeAddRefPolicy>
{

public: 
	static HRESULT Create(RefreshAlignedClock * * ppClock);
	virtual XDOUBLE Tick();
	virtual XDOUBLE GetLastTickTimeInSeconds();
	virtual XDOUBLE GetNextTickTimeInSeconds();
	void SetRefreshRateInfo(struct IPALRefreshRateInfo * pRefreshRateInfo);

private: 
	RefreshAlignedClock();
	virtual ~RefreshAlignedClock();
	HRESULT Initialize();
	struct IPALClock * m_pIClock;
	struct IPALCriticalSection * m_pLock;
	XDOUBLE m_lastReportedTime;
	struct IPALRefreshRateInfo * m_pRefreshRateInfo;
};